The main entry point for the 24-game solver, utilizing recursive search, progress bar, and OpenMP parallelization.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | max_limit | = | 8 |
Maximum allowed value for the number of inputs |
integer, | public, | parameter | :: | expr_len | = | 200 |
Maximum length for expressions |
integer(kind=int64), | public, | parameter | :: | total_calls_n6 | = | 20000000_int64 |
Precomputed total recursive calls for n=6 |
integer(kind=int64), | public, | parameter | :: | total_calls_n7 | = | 2648275200_int64 |
Precomputed total recursive calls for n=7 |
integer(kind=int64), | public, | parameter | :: | total_calls_n8 | = | 444557593600_int64 |
Precomputed total recursive calls for n=8 |
integer(kind=int64), | public | :: | total_calls | = | 0 |
Total number of recursive calls |
|
integer(kind=int64), | public | :: | completed_calls | = | 0 |
Number of completed recursive calls |
|
integer, | public | :: | last_percentage | = | -1 |
Last percentage reported |
|
integer, | public, | parameter | :: | progress_bar_width | = | 50 |
Width of the progress bar |
character(len=1), | public | :: | carriage_return | = | char(13) |
Carriage return character |
|
logical, | public | :: | show_progress | = | .false. |
Flag to show progress bar |
Converts user input (cards or numbers) into numeric values. Handles card values such as 'A', 'J', 'Q', 'K'.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | input_str |
Input: String representing the number or card value. |
||
real, | intent(out) | :: | number |
Output: The corresponding numeric value after conversion. |
||
integer, | intent(out) | :: | ios |
Output: I/O status indicator (0 for success). |
Removes trailing zeros after the decimal point in a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str |
Input: String to remove zeros from. |
||
character(len=*), | intent(out) | :: | result |
Output: String without trailing zeros. |
Creates new arrays after performing an operation.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real, | intent(in) | :: | nums(:) |
Input: Array of numbers. |
||
character(len=expr_len), | intent(in) | :: | exprs(:) |
Input: Array of expressions. |
||
integer, | intent(in) | :: | idx1 |
Input: Indices of elements to remove. |
||
integer, | intent(in) | :: | idx2 |
Input: Indices of elements to remove. |
||
real, | intent(in) | :: | result |
Input: Result of the operation. |
||
character(len=expr_len), | intent(in) | :: | new_expr |
Input: New expression for the result. |
||
real, | intent(out), | allocatable | :: | new_nums(:) |
Output: New array of numbers with elements removed and result added. |
|
character(len=expr_len), | intent(out), | allocatable | :: | new_exprs(:) |
Output: New array of expressions with elements removed and new_expr added. |
Updates and displays the horizontal percentage-based progress bar.
Recursively solves the 24 game by trying all possible operations. Utilizes OpenMP tasks for parallelization.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real, | intent(in) | :: | nums(:) |
Input: Array of numbers. |
||
character(len=expr_len), | intent(in) | :: | exprs(:) |
Input: Array of string expressions representing the numbers. |
||
logical, | intent(inout) | :: | found |
Input/Output: Flag indicating if a solution is found. |